﻿using NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Linq;
using GENERIC.Respository.Interfaces;

namespace GENERIC.NHRepository
{
    public class NHSet<T> : IGENERICSet<T> where T : class, new()
    {
        #region Constructor

        public NHSet(ISession session)
        {
            Session = session;
        }

        #endregion

        #region Properties

        private ISession Session { get; set; }

        #endregion


        public void Insert(T entity)
        {
            Session.Save(entity);
        }

        public void Update(T entity)
        {
            Session.Update(entity);
        }

        public void Delete(T entity)
        {
            Session.Delete(entity);
        }

        public IQueryable<T> Get()
        {
            return Session.Query<T>();
        }
    }
}
